package com.whz.streamdemo;

import lombok.extern.slf4j.Slf4j;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

import static java.math.BigInteger.ONE;
import static java.math.BigInteger.TWO;

/**
 * @Author: sinosoft
 * @Description: 打印前20个梅森素数
 * @Date: Create in 10:24 2021/5/18
 * @Modified By:
 */
@Slf4j
public class MersennePrimesMainTest {
    public static void main(String[] args) {
        MersennePrimes.primes().parallel().map(
                p -> TWO.pow(p.intValueExact()).subtract(ONE))
                      .filter(mersenne -> mersenne.isProbablePrime(50))
                      .limit(20)
                      .forEach(mp -> System.out.println(mp.bitLength() + ": " + mp));
//        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
//        Calendar calendar = Calendar.getInstance();
//        String dateStr = sdf.format(calendar.getTime());
//        log.info("dateStr: {}", dateStr);
//        log.info("calendar: {}", calendar);
//        calendar.set(2021, 4, 14);
//        log.info("calendar: {}", calendar.getTime());
//        Date date = calendar.getTime();
//        String dateStr2 = sdf.format(date);
//        log.info("dateStr: {}", dateStr2);


    }
}
